// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UcDatabase.cs" company="SmartPlan">
//   SmartPlan 2011
// </copyright>
// <summary>
//   The uc database.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


namespace DbDiff.WinClient.Forms.DbItems
{
    using System.ComponentModel;
    using Common.Helper;
    using Common.Model;

    /// <summary>
    /// The uc database.
    /// </summary>
    public class UcDatabase : UcDbItem
    {
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="UcDatabase"/> class.
        /// </summary>
        /// <param name="data">
        /// The data.
        /// </param>
        public UcDatabase(DatabaseInfo data)
        {
            this.InitializeComponent();
            this.Data = data;

            this.Init();
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UcDatabase"/> class.
        /// </summary>
        public UcDatabase()
        {
            this.InitializeComponent();

            this.Init();
        }

        /// <summary>
        /// The init.
        /// </summary>
        private void Init()
        {
            this.HeaderVisible = true;

            this.DetailsControl = new UcItemProperties(string.Empty);
            this.Toolbar = null;
            this.CommandMenu = null;

            this.Title = "Database properties";
        }

        #endregion Constructors

        #region Form view / data update

        /// <summary>
        /// Updates the form data.
        /// </summary>
        protected override void UpdateFormData()
        {
            this.LblHeader.Text = this.Title;
            ((UcItemProperties) this.DetailsControl).SetData(
                ((DatabaseInfo) this.Data).GetRawDatatable(DatabaseObjectTypes.Database).Rows[0]);
        }

        #endregion Form view / data update

        #region SetData

        /// <summary>
        /// The set data.
        /// </summary>
        /// <param name="names">
        /// The names.
        /// </param>
        /// <param name="values">
        /// The values.
        /// </param>
        public void SetData(string[] names, string[] values)
        {
            if (this.DetailsControl != null)
                ((UcItemProperties) this.DetailsControl).SetData(names, values);
        }

        #endregion SetData

        #region Designer generated code

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">
        /// The disposing.
        /// </param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
            }

            base.Dispose(disposing);
        }

        /// <summary>
        /// Required method for Designer support - do not modify
        ///   the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
        }

        #endregion
    }
}